<a href="<?php echo $this->href('/sitemap');?>">
<?php echo $this->translate('catalog')->__('Categories')?>
</a>
<a href="<?php echo $this->href('/sitemap/get-all-products') ?>">
<?php echo $this->translate('catalog')->__('All Products')?>
</a>
<a href="<?php echo $this->href('/sitemap/get-all-pages')?>">
<?php echo $this->translate('cms')->__('Pages')?>
</a>
<hr/>
<span>
<?php echo count($this->items) - 1 .  " " . $this->translate('core')->__("Item(s)");?>
</span>
<ul class="tree">
<?php
unset($this->items['siteId']);
foreach ($this->items as $id => $item) {

    $prev = $item['lvl'];
    $next = isset($this->items[$id + 1]) ? $this->items[$id + 1] : 'null';
    ?>
    <li><a href="<?php echo $this->hurl(array(
            'cat' => array('value' => $item['id'], 'seo' => $item['key_word']),
            'controller' => 'catalog',
            'action' => 'view'
        ), false, true);?>"><?php echo $this->escape($item['name']);?></a>
    <?php
    if ($next['lvl'] < $item['lvl'] || $next == 'null') {
        echo  "</li>";
        if ($next != 'null' ) {
            echo str_repeat("</ul></li>", $item['lvl'] - $next['lvl'] );
        } else {
            echo "</ul>";
            echo str_repeat("</li></ul>", $item['lvl'] - $next['lvl'] - 1);  ;
        }
    } elseif ($next['lvl'] > $item['lvl'] && $prev > -1) {
       echo  "<ul>";
    } else {
       echo  "</li>";
    }
}
?>

<br />
<ul>
    <li>
        <a href="<?php echo $this->href('search/') ?>"
            rel="nofollow">
            <?php echo $this->translate('search')->__('Advanced Search')?>
        </a>
    </li>
    <li>
        <a href="<?php echo $this->href('checkout/cart/', true) ?>"
            rel="nofollow">
            <?php echo $this->translate('checkout')->__('Shopping Cart')?>
        </a>
    </li>
    <li>
        <a href="<?php echo $this->href($this->catalogUrl) ?>">
            <?php echo $this->translate('catalog')->__('Products')?>
        </a>
    </li>
    <li>
        <a href="<?php echo $this->href('account', true) ?>"
            rel="nofollow">
            <?php echo $this->translate('account')->__('Account')?>
        </a>
    </li>
    <li>
        <a href="<?php echo $this->href('contacts') ?>"
            rel="nofollow">
            <?php echo $this->translate('contacts')->__('Contact Us')?>
        </a>
    </li>
</ul>